Skip to content

Enable "useDefineForClassFields" in tsc --init #39362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

robpalme
Copy link

@robpalme robpalme commented Jul 1, 2020

Fixes #39311

This changes adds "useDefineForClassFields": true to the default tsconfig.json generated by tsc --init. The impact is that new projects will adopt standard browser semantics. Existing projects are not affected.

Please forgive the whitespace noise in the the test baselines. The new comma after "forceConsistentCasingInFileNames" results in a one-character column of whitespace rippling upwards.

  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the master branch
  • You've successfully run gulp runtests locally
  • There are new or updated unit tests validating the change

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to make this change until we decide as a team that the bulky es5 emit is the right default.
Besides, since 4.0, I don't think you can write an error-free program that exposes the difference between Set and Define.

@sandersn
Copy link
Member

sandersn commented Sep 2, 2020

The design meeting ended up with a laundry list of options we aren't sure whether to recommend in --init:

  • useDefineForClassFields - maybe not great because the emit isn't great.
  • jsx: react? Sure
  • declaration: true? Okay
  • moduleResolution: node? Sure
  • module: esnext? Uh
  • declarationMap: true?: Okay...
  • incremental: true? Ugh, right, yes.

So I think we need to discuss this again in the design meeting. @DanielRosenwasser

@sandersn sandersn self-assigned this Oct 27, 2020
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 27, 2020
@sandersn
Copy link
Member

After discussing this in the design meeting, this is on hold until the target ES version is the one that has Define semantics by default.

@sandersn
Copy link
Member

I'm going to close this PR to keep things tidy since it's not clear when Define will be part of the standard.

Also, since esnext now implies useDefineForClassFields, setting the target will imply the correct value, whether it's esnext or es20xx.

@sandersn sandersn closed this Mar 10, 2021
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #39311. If you can get it accepted, this PR will have a better chance of being reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Enable "useDefineForClassFields" in tsc --init
4 participants